//
//  WDRootZhuangBei1ViewController.m
//  qiJi
//
//  Created by 凤利史 on 2018/3/29.
//  Copyright © 2018年 sunrose. All rights reserved.
//

#import "WDRootZhuangBei1ViewController.h"
#import "WDRootZhuangBeiCollectionViewCell.h"
@interface WDRootZhuangBei1ViewController ()<UICollectionViewDelegate, UICollectionViewDataSource>
@property (nonatomic, strong) UICollectionView *collectionView;

@end

@implementation WDRootZhuangBei1ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void)zj_viewDidLoadForIndex:(NSInteger)index {
    
    [self configLayout];
    self.view.backgroundColor = getColor(@"FAFAFA");
    
    
}
- (void)zj_viewWillAppearForIndex:(NSInteger)index {
    // NSLog(@"viewWillAppear------");
    
    
}


- (void)zj_viewDidAppearForIndex:(NSInteger)index {
    // NSLog(@"viewDidAppear-----");
    
}

- (void)configLayout{
    
    NSString *version = [UIDevice currentDevice].systemVersion;
    if (version.doubleValue >= 9.0) {
        // 针对 9.0 以上的iOS系统进行处理
    } else {
        
        // 针对 9.0 以下的iOS系统进行处理
    }
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - (KIsiPhoneX?84:64) - 42) collectionViewLayout:layout];
    [self.view addSubview:self.collectionView];
    //
    [self.collectionView layoutIfNeeded];
    //    self.automaticallyAdjustsScrollViewInsets = NO;
    self.collectionView.pagingEnabled = NO;
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    
    [self.collectionView registerNib:[UINib nibWithNibName:@"WDRootZhuangBeiCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"WDRootZhuangBeiCollectionViewCell"];
    
    self.collectionView.showsHorizontalScrollIndicator = NO;
    
    //    self.collectionView.bounces = NO;
    self.collectionView.backgroundColor = getColor(@"FAFAFA");
     
}
//类别
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
    
}
//数量
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    
    return 12;
    
    
}
//设置每个 UICollectionView 的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
        
        return CGSizeMake((DEF_SCREEN_WIDTH-40)/2, 160);
    
    
}

//定义每个UICollectionView 的间距
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    
        return UIEdgeInsetsMake(15, 15, 15, 15);
    
    
}

//定义每个UICollectionView 的横向间距
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    
    return 10;
}

//内容

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    WDRootZhuangBeiCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WDRootZhuangBeiCollectionViewCell" forIndexPath:indexPath];

    return cell;
    
    
    
}
//点击
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
   
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
